package com.dimples.constant;

import java.util.Map;

import cn.hutool.core.map.MapUtil;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2020/1/21
 */
public class SQLConstant {

    public static Map<String, String> mysqlToCacheReplace = MapUtil.newHashMap();

    public static Map<String, String> cacheToMysqlReplace = MapUtil.newHashMap();

    public static Map<String, String> cacheToMysqlRegReplace = MapUtil.newHashMap();

    static {
        mysqlToCacheReplace.put("longblob", "varchar(4096)");
        mysqlToCacheReplace.put("sysdate()", "GETDATE()");
    }

    static {
        mysqlToCacheReplace.put("DATE", "varchar(4096)");
        mysqlToCacheReplace.put("TIME", "GETDATE()");
    }

    static {
        cacheToMysqlRegReplace.put("DATE\\([0-9]+\\)", "date");
        cacheToMysqlRegReplace.put("TIME\\([0-9]+\\)", "time");
        cacheToMysqlRegReplace.put("VARCHAR\\([0-9]{4,9}+\\)", "text");
        cacheToMysqlRegReplace.put("LONGVARCHAR\\(.*\\)", "text");
        cacheToMysqlRegReplace.put("LONGVARBINARY\\(.*\\)", "text");
        cacheToMysqlRegReplace.put("TIMESTAMP\\([0-9]{0,5}\\,[0-9]{0,5}\\)", "datetime");
        cacheToMysqlRegReplace.put("limit\\s", "`limit` ");
        cacheToMysqlRegReplace.put("order\\s", "`order` ");
        cacheToMysqlRegReplace.put("release\\s", "`release` ");
        cacheToMysqlRegReplace.put("releases\\s", "`releases` ");
        cacheToMysqlRegReplace.put("default\\s\\'.*\\'", "");
        cacheToMysqlRegReplace.put("default\\s\\$i\\(.*\\)", "");
        cacheToMysqlRegReplace.put("default\\s\\$I\\(.*\\)", "");
    }

    /**
     * 系统名称
     */
    public static final String SCHEMA_NAME = "mdm_User";
    public static final String SCHEMA_NAME_DOT = "mdm.User";

    /**
     * SQL连接词
     */
    public static final String SQL_CONJ_AND = " AND ";

    /**
     * SQL连接词
     */
    public static final String SQL_CONJ_WHERE = " WHERE ";
    public static final String SQL_SELECT = "SELECT ";
    public static final String SQL_FROM = " FROM ";
    public static final String SQL_CREATE_TABLE = "CREATE TABLE ";
    public static final String SQL_INSERT_INTO = "INSERT INTO ";
    public static final String SQL_VALUES = "VALUES";

    public static final String MYSQL_ENGINE = " engine=innodb ";
    public static final String MYSQL_COMMENT = " comment";

}
